#include "window.h"

LRESULT CALLBACK Window::ooDispatcher(
	HWND hWnd,
	UINT uMsg,
	WPARAM wParam,
	LPARAM lParam )
{
	Window *instance = (Window*) GetWindowLongPtr( hWnd, GWLP_USERDATA );
	if( instance )
	{
		//Pass the message on to the T-type instance.
		LRESULT lResult = instance->handleMessage( uMsg, wParam, lParam );
		if( uMsg == WM_NCDESTROY )
		{
			//The window is destroyed.
			delete instance;
		}
		return lResult;
	}
	return DefWindowProc( hWnd, uMsg, wParam, lParam );
}